package n.d.l.svn.service;

import java.io.File;
import java.io.IOException;
import java.util.List;

import n.d.l.svn.bean.PatchLog;
import n.d.l.svn.mapper.log.PatchLogMapper;

import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(readOnly=false)
public class PatchLogService {

	@Autowired
	private PatchLogMapper patchLogMapper;
	@Value("${patch.log.path}")
	private String logPath;
	
	public List<PatchLog> findList(PatchLog log){
		return patchLogMapper.findList(log);
	}

	public List<String> logDetail(PatchLog log) {
		try {
			return FileUtils.readLines(new File(logPath + log.getLogPath() + ".log"), "utf-8");
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
}
